# Build recipe for musl.
#
# Copyright (C) 2015-2017 Matias A. Fonzo, selk@dragora.org.
# Copyright (C) 2017 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# This recipe is free software: you have unlimited permission
# to copy, distribute and modify it.

program=musl
version=1.1.16
release=1

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=http://www.musl-libc.org/releases/$tarname

description="
A powerful standard C/POSIX library.

Musl is a new standard library to power a new generation of Linux-based
devices.  Musl is lightweight, fast, simple, free, and strives to be
correct in the sense of standards-conformance and safety.
"

homepage=http://www.musl-libc.org
license=MIT

# Source documentation
docs="COPYRIGHT README VERSION WHATSNEW"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    patch -Np0 -i "/home/mprodrigues/repositories/dragora/patches/musl/musl-utmp_path.diff"

    ./configure --prefix=/opt/musl \
     --enable-shared \
     --enable-static \
     --enable-optimize=size

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs
    do
        cp -p $file "${destdir}${docsdir}"
    done
}
